home *** CD-ROM | disk | FTP | other *** search
/ Scene Storm / Scene Storm - Volume 1.iso / coding / c / amiexpress / source / doors / global / global.c next >
Encoding:
C/C++ Source or Header  |  1992-12-26  |  5.3 KB  |  208 lines

  1.  
  2. #include <exec/exec.h>
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include "XIM:doorheader.h"
  6. #include "XIM:glue.h"
  7.  
  8. struct User {
  9.  char    Name[31],Pass[9],Location[30],PhoneNumber[13];
  10.  USHORT  Slot_Number;
  11.  USHORT  Sec_Status,
  12.      Sec_Board,                   /* File or Byte Ratio */
  13.      Sec_Library,                 /* Ratio              */
  14.      Sec_Bulletin,                /* Computer Type      */
  15.      Messages_Posted;
  16.  /* Note ConfYM = the last msg you actually read, ConfRead is the same ?? */
  17.  ULONG   NewSinceDate, ConfRead1, ConfRead2, ConfRead3, ConfRead4,
  18.          ConfRead5;
  19.  UWORD   XferProtocol, Filler2;
  20.  UWORD   Lcfiles,BadFiles; 
  21.  ULONG   AccountDate;
  22.  UWORD   ScreenType, Filler1;
  23.  char    Conference_Access[10];
  24.  USHORT  Uploads, Downloads, ConfRJoin, Times_Called;
  25.  long    Time_Last_On, Time_Used, Time_Limit, Time_Total;
  26.  ULONG   Bytes_Download, Bytes_Upload, Daily_Bytes_Limit, Daily_Bytes_Dld;
  27.  char    Expert;
  28.  ULONG   ConfYM1, ConfYM2, ConfYM3, ConfYM4, ConfYM5, ConfYM6, ConfYM7,
  29.          ConfYM8, ConfYM9;
  30.  long    BeginLogCall;
  31.  UBYTE   Protocol, UUCPA, LineLength, New_User;
  32.  };
  33. struct UserKeys {                 /* changes to UserKeys (RTS) */
  34.  char    UserName[31];
  35.  long    Number;
  36.  UBYTE   New_User;
  37.  UWORD   UPcps;              /* highest upload cps rate */
  38.  UWORD   DNcps;              /* highest dnload cps rate */
  39.  UWORD   Userflags;          /*                         */
  40.  UWORD   baud_rate;          /* last online baud rate   */
  41.  char    Pad[9];             /* ?? should be 15         */
  42. };
  43.  
  44. struct User U;
  45. struct UserKeys UK;
  46.  
  47. void ShowIntro(void);
  48. char VaultCfg[200];
  49. char bbsroot[200];
  50. ULONG ShowValue(ULONG Value);
  51. FILE *CreateDataBase(char *s);
  52. void end(void);
  53. void LastCommand(void);
  54. char path[200];
  55. #define sm sendmessage
  56. #define gu getuserstring
  57. #define pm prompt
  58. #define hk hotkey
  59. #define pu putuserstring
  60. main(int argc,char *argv[])
  61. {
  62.   FILE *fi,*fo;
  63.   register int i;
  64.   int num;
  65.   ULONG Value;
  66.   if(argc!=2)
  67.   {
  68.     printf("\n");
  69.     printf("Bank version 1.0 , written by Joseph Hodge\n");
  70.     printf("This is a product of the /X Developement Team - The Silent Achievers\n");
  71.     printf("This is a (XIM) for AmiExpress 3.0+\n");
  72.     printf("\n");
  73.     exit(0);
  74.   }
  75.   Register(argv[1][0]-'0');
  76.   strcpy(path,argv[0]);
  77.   gu(bbsroot,DT_SLOTNUMBER);
  78.   ShowIntro();
  79.   i=strlen(path)-1;
  80.   while(i)
  81.   {
  82.     if(path[i]==':' || path[i]=='/') {path[i+1]='\0'; break; }
  83.     i--;
  84.   }
  85.   num=atoi(bbsroot);
  86.   sprintf(VaultCfg,"%sBank.cfg",path);
  87.   fi=fopen(VaultCfg,"r+b");
  88.   if(fi==NULL) fi=CreateDataBase(VaultCfg);
  89.   if(fi==NULL)
  90.   {
  91.     sm("",1);
  92.     sm("Error creating Database",1);
  93.     sm("",1);
  94.     ShutDown();
  95.     end();
  96.   }
  97.   if(!fseek(fi,(ULONG)sizeof(ULONG)*(ULONG)(num-1),0L))
  98.   {
  99.     fread((APTR)&Value,sizeof(ULONG),1,fi);
  100.     
  101.   }
  102.   else
  103.   {
  104.     sm("",1);
  105.     sm("Records indicate that you do not have an Account",1);
  106.     sm("established with this BANK.",1);
  107.     sm("",1);
  108.     ShutDown();
  109.     end();
  110.   }
  111.   fclose(fi);
  112.   Value=ShowValue(Value);
  113.  fi=fopen(VaultCfg,"r+b");
  114.  
  115.    if(!fseek(fi,(ULONG)sizeof(ULONG)*(ULONG)(num-1),0L))
  116.   {
  117.     fwrite((APTR)&Value,sizeof(ULONG),1,fi);
  118.     
  119.   }
  120.   fclose(fi);
  121.   ShutDown();
  122.   end();
  123. }
  124. ULONG ShowValue(ULONG Value)
  125. {
  126.   char image[100];
  127.   ULONG Current=0L;
  128.   ULONG Temp=0L;
  129.   sm("",1);
  130.   gu(image,DT_BYTESUPLOAD);
  131.   Current=atol(image);
  132.   sm("--------------------------------------",1);
  133.   sm("Online            | In The Bank      ",1);
  134.   sm("--------------------------------------",1);
  135.   sprintf(image,"%-18ld%-18ld",Current,Value);
  136.   sm(image,1);
  137.   sm("",1);
  138.   pm("Enter Amount to transfer to current conference >: ",image,15);
  139.   Temp=atol(image);
  140.   if(Temp<=Value && Temp!=0L) 
  141.   {
  142.     Current +=Temp;
  143.     Value -=Temp;
  144.     sprintf(image,"%ld",Current);
  145.     pu(image,DT_BYTESUPLOAD);
  146.     sm("Updating Account...",1);
  147.     sm("",1);
  148.   sm("--------------------------------------",1);
  149.   sm("Online            | In The Bank      ",1);
  150.   sm("--------------------------------------",1);
  151.   sprintf(image,"%-18ld%-18ld",Current,Value);
  152.   sm(image,1);
  153.   sm("",1);
  154.  
  155.   }
  156.   return(Value);
  157. }
  158. FILE *CreateDataBase(char *s)
  159. {
  160.    FILE *fi;
  161.    ULONG Value;
  162.    char image[200];
  163.    int num=1;
  164.    sm("",1);
  165.    sm("Standby.. Creating Database..",1);
  166.    sm("",1);
  167.    fi=fopen(s,"wb");
  168.    if(fi!=NULL)
  169.    {
  170.    while(Load_Account(num,(APTR)&U,(APTR)&UK))
  171.    {
  172.      Value=0L;
  173.      if(U.Sec_Library==0)
  174.      {
  175.        Value=U.Bytes_Upload;
  176.      }
  177.      else
  178.      {
  179.         Value=U.Bytes_Upload-((ULONG)(U.Sec_Library)*U.Bytes_Download);
  180.      }
  181.      fwrite((APTR)&Value,sizeof(ULONG),1,fi);
  182.     num++; 
  183.   }
  184.   fclose(fi);
  185.   fi=fopen(s,"r+b"); return(fi);
  186.   }
  187.   return(fi);
  188. }
  189.   
  190. void ShowIntro(void)
  191. {
  192.   sm("",1);
  193. sm(" .------------------------------------------------------------------------.",1);
  194. sm(" |            Ami-Express GLOBAL Version 1.0 Written by ByteMaster          |",1);
  195. sm(" |                /X Development Team - The Silent Achievers              |",1);
  196. sm(" `------------------------------------------------------------------------'",1);
  197.  sm("",1);
  198. }
  199.  
  200. void LastCommand(void)
  201. {
  202.   sm("",1);
  203.   sm("",1);
  204. }
  205. void end(void)
  206. {
  207.    exit(0);
  208. }